package leetCode;

import java.util.*;

public class t49 {
    public static void main(String[] args) {
        String[] strs=new String[]{"bdddddddddd","bbbbbbbbbbc"};
        new Solution49().groupAnagrams(strs);
    }
}
class Solution49 {
    public List<List<String>> groupAnagrams(String[] strs) {
        HashMap<String,List<String>>hashMap=new HashMap<>();
        for (String str:strs){
            char[] array = str.toCharArray();
            Arrays.sort(array);
            String arrayString = new String(array);
            List<String> strings = hashMap.getOrDefault(arrayString, new ArrayList<String>());
            strings.add(str);
            hashMap.put(arrayString,strings);
        }
        List<List<String>> retList=new ArrayList<>();
        Set<Map.Entry<String, List<String>>> entries = hashMap.entrySet();
        for (Map.Entry<String, List<String>> entry:entries){
            retList.add(entry.getValue());
        }
        return retList;
    }
}
